package com.libertyville.adapter.driving.restful.orgmng;

import com.libertyville.application.orgmng.CreateOrgRequest;
import com.libertyville.application.orgmng.OrgResponse;
import com.libertyville.application.orgmng.OrgService;
import com.libertyville.application.orgmng.UpdateOrgBasicRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/libertyville")
public class OrgController {
    private OrgService orgService;

    @Autowired
    public OrgController(OrgService orgService) {
        this.orgService = orgService;
    }

    @PostMapping("/api/organizations/add")
    public OrgResponse addOrg(@RequestBody CreateOrgRequest request) {
        return orgService.addOrg(request, "Sam Jiang");
    }

    @PostMapping("/api/organizations/{orgId}/update")
    public OrgResponse updateOrg(@PathVariable("orgId") Integer orgId, @RequestBody UpdateOrgBasicRequest request) {
        return orgService.updateOrgBasic(orgId, request, "Sam Jiang");
    }

    @PostMapping("/api/organizations/{orgId}/cancel")
    public Integer cancelOrg(@PathVariable("orgId") Integer orgId) {
        return orgService.cancelOrg(orgId, "Sam Jiang");
    }
}
